<?php
/*--------------------------------------------------*
 *    WSG Designs [http://dragonfly.wsgdesigns.com] *
 *         Copyright © 2007 by WSG Designs          *
 *--------------------------------------------------*
 * Theme Name:	Cardinal                            *
 * Author:		WebSiteGuru Designs                 *
 * Author Website:	http://www.wsgdesigns.com       *
 * Released:   		               *
 * Version:    		9.2.1.1                  	        *
 *--------------------------------------------------*
 *  Theme created for CPG Dragonfly™ CMS 9.2.1    *
 *          http://www.dragonflycms.com             *
 *--------------------------------------------------*
 *    This theme is released under the terms and    *
 *    conditions of the GNU GPL version 2 or any    *
 *                later revisions.                  *
 *--------------------------------------------------*
 * Modification to the Theme:
 *	You are authorized to make any modification as you see fit for your site,
 *  so as long as all Copyrights stay in tact.
 *
 * All Copyrights to the Theme is reserved to WSG Designs (http://www.wsgdesigns.com) and the Author WebSiteGuru of WSG Designs. (http://www.wsgdesigns.com)
 *
 * All Graphics are Copyrights of its owner(s).
 *
 * Redistribution of the Theme:
 *	You may redistribute the unmodified Theme only as FREE Theme ONLY.
 *  You may not redistribute modified versions of this theme without permission from WSGDesigns
 *	You can not and may not resell any of the portion of this Theme even after modification to the Theme had been done.
 *
 * Porting to other CMS:
 *	You may not port this Theme to other CMS, unless you get written permission by WebSiteGuru Designs (wsgdesigns@gmail.com)
 */
if (!defined('CPG_NUKE')) { exit; }
define('THEME_VERSION', '9.2.1.2');

$gfxcolor = '#0000FF';
$bgcolor1 = '#FFFFFF';
$bgcolor2 = '#E9E9E9';
$bgcolor3 = '#E9E9E9';
$bgcolor4 = '#CCCCCC';
$textcolor1 = '#0000FF';
$textcolor2 = '#0000FF';
$hr = 1; # 1 to have horizonal rule in comments instead of table bgcolor

function OpenTable() {
	echo '<div class="table1">';
}
function OpenTable2() {
	echo '<div class="table2">';
}

function CloseTable() {
	echo '</div>';
}
function CloseTable2() {
	echo '</div>';
}

function themeheader() {
	global $slogan, $sitename, $banners, $mainindex, $adminindex, $cpgtpl, $site_logo, $CPG_SESS, $MAIN_CFG, $userinfo, $Blocks;
	if ($MAIN_CFG['global']['admingraphic'] & 4) {
		include('themes/'.$CPG_SESS['theme'].'/cssmainmenu.php');
	}
	$imgr = $imgl = '';
	// left blocks ?
	if ($Blocks->l && ($Blocks->showblocks & 1)) {
		$img = $Blocks->hideblock('600') ? 'plus.gif' : 'minus.gif';
		$imgl = '<img alt="'._TOGGLE.'" title="'._TOGGLE.'" id="pic600" src="themes/'.$CPG_SESS['theme'].'/images/'.$img.'" onclick="blockswitch(\'600\');" style="cursor:pointer; float:left; padding:2px 0 2px 0;" />';
	}
	// right blocks ?
	if ($Blocks->r && ($Blocks->showblocks & 2)) {
		$img = $Blocks->hideblock('601') ? 'plus.gif' : 'minus.gif';
		$imgr = '<img alt="'._TOGGLE.'" title="'._TOGGLE.'" id="pic601" src="themes/'.$CPG_SESS['theme'].'/images/'.$img.'" onclick="blockswitch(\'601\');" style="cursor:pointer; float:right; padding:2px 0 2px 0;" />';
	}
	$user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '';
	$css_ie = ereg('MSIE 7.0', $user_agent) ? 'ie7' : (ereg('MSIE ([0-6].[0-9]{1,2})', $user_agent) ? 'ie6' : ((isset($_SESSION['SECURITY']['UA']) && $_SESSION['SECURITY']['UA'] == 'Safari') ? 'safari' : ((isset($_SESSION['SECURITY']['UA']) && $_SESSION['SECURITY']['UA'] == 'Opera') ? 'opera' : '')));
    // Number of New Messages
    $num_new_pm = $userinfo['user_new_privmsg']+$userinfo['user_unread_privmsg'];
	$flash = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="360" height="80" id="logo"><param name="movie" value="themes/'.$CPG_SESS['theme'].'/images/logo.swf" /><param name="menu" value="false" /> <param name="quality" value="best" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#AEBFCC" /><embed src="themes/'.$CPG_SESS['theme'].'/images/logo.swf" menu="false" quality="best" wmode="transparent" bgcolor="#AEBFCC" width="360" height="80" name="logo"></embed></object>';
	$cpgtpl->assign_vars(array(
		'CSS_IE'		=> ($css_ie) ? '<link rel="stylesheet" type="text/css" href="themes/'.$CPG_SESS['theme'].'/style/'.$css_ie.'.css" />' : '',
		'S_TOGGLE'		=> _TOGGLE,'PUBLIC_HEADER' => !defined('ADMIN_PAGES'),
		'B_L_VISIBLE'  => $Blocks->hideblock('600') ? 'style="display: none"' : '',
		'G_LEFTIMAGE'  => $imgl,
		'G_RIGHTIMAGE' => $imgr,
		'S_IS_ADMIN'   => is_admin(),
		'S_CAN_ADMIN'  => can_admin(),
		'S_IS_USER'    => is_user(),
		'S_LOGO'       => $site_logo,
		'S_FLASH'      => $flash,
		'S_SITENAME'   => $sitename,
		'S_HOME'       => _HOME,
		'S_DOWNLOADS'  => is_active('Downloads') ? _DownloadsLANG : false,
		'S_FORUMS'     => _ForumsLANG,
		'S_MY_ACCOUNT' => is_user() ? _Your_AccountLANG : _BREG,
		'S_ADMIN'      => _ADMINISTRATION,
		'S_BANNER'     => ($banners) ? viewbanner() : '',
		'U_MAININDEX'  => $mainindex,
		'U_DOWNLOADS'  => getlink('Downloads'),
		'U_FORUMS'     => getlink('Forums'),
		'U_MY_ACCOUNT' => getlink(is_user() ? 'Your_Account' : 'Your_Account&amp;file=register'),
		'U_ADMININDEX' => $adminindex,
		'S_MAIN_MENU'  => isset($mmcontent) ? $mmcontent : false,
		'S_WELCOME'    => _BWEL.' '.(is_user() ? ' '.$userinfo['username'].', you have <a href="index.php?name=Private_Messages">'.$num_new_pm.' new messages.</a>': 'Please <a href="index.php?name=Your_Account&amp;file=register">Register</a> or <a href="index.php?name=Your_Account">Login</a>'),
		'S_NEWS'       => _NewsLANG,
		'S_GALLERY'    => is_active('coppermine') ? _coppermineLANG : false,
		'U_NEWS'       => getlink('News'),
		'U_FORUMS'     => getlink('Forums'),
		'U_FAQ'        => getlink('Forums&file=faq'),
		'U_GALLERY'    => getlink('coppermine'),
		'U_SEARCH'     => getlink('Forums&file=search'),
		'U_PROFILE'    => getlink('Your_Account'),
		'U_MEMBERLIST' => getlink('Members_List'),
		'U_LOGIN_LOGOUT'   => getlink('Your_Account&Redirect=1'),
		'U_PRIVATEMSGS'    => getlink('Private_Messages'),
		'U_GROUPS'    => getlink('Groups'),
		'DL_SEARCH'		=> getlink('Downloads&amp;file=search'),
		'DL_MYDL'		=> getlink('Downloads&file=manage'),
		'DL_ADDDL'		=> getlink('Downloads&file=add'),
		'DL_RANDDL'		=> getlink('Downloads&mode=random'),
	));
	$Blocks->display('l');
}

function themefooter() {
	global $showblocks, $banners, $cpgtpl, $foot1, $foot2, $foot3, $copyright, $db, $Blocks;
	$Blocks->display('r');
	$version = '<br />Version 9.2.1.2 - July 1, 2008';
	$credits = 'Cardinal Theme orginally By: <a href="http://www.lorkan.com/">Lorkan Themes</a>.';
  $WSG_credits = ' - Ported to DragonflyCMS by: <a href="http://dragonfly.wsgdesigns.com">WebSiteGuru Designs</a>';
	
	$cpgtpl->assign_vars(array(
		'B_R_VISIBLE'   => $Blocks->hideblock('601') ? 'style="display: none"' : '',
		'B_R_HIDDEN'    => $Blocks->hideblock('601') ? '' : 'style="display: none"',
		'S_FOOTER'      => footmsg(),
		'S_FOOTER_2'      => $credits.$WSG_credits.$version,
	));
	$cpgtpl->set_filenames(array('footer' => 'footer.html'));
	$cpgtpl->display('footer');
}


/***********************************************************************************

 string theme_open_form

 Creates start tag for form
	$get_link : link for action default blank
	$form_name : useful for styling and nbbcode
	$legend: optional string value is used in form lagend tag
	$border: optional use 1 to not show border on fieldset from stylesheet
************************************************************************************/
function theme_open_form($link, $form_name=false, $legend=false,$tborder=false) {
	$leg = $legend ? "<legend>$legend</legend>" : '';
	$bord = $tborder ? $tborder : '';
	$form_name	= $form_name ? ' name="'.$form_name.'" id="'.$form_name.'"' :'';
	return '<fieldset '.$bord.'>'.$leg.'<form method="post" action="'.$link.'"'.$form_name.' enctype="multipart/form-data" accept-charset="utf-8">';
}
function theme_close_form() {
	return '</form></fieldset>';
}
/***********************************************************************************

 string theme_yesno_option

 Creates 2 radio buttons with a Yes and No option
	$name : name for the <input>
	$value: current value, 1 = yes, 0 = no

************************************************************************************/
function theme_yesno_option($name, $value=0) {
	$sel[(!$value)] = '';
	$sel[$value] = ' selected="selected"';
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	$select .= '<option value="1"'.$sel[1].">"._YES."</option>\n";
	$select .= '<option value="0"'.$sel[0].">"._NO."</option>\n";
	return $select.'</select>';
}
/***********************************************************************************

 string theme_select_option

 Creates a selection dropdown box of all given variables in the array
	$name : name for the <select>
	$value: current/default value
	$array: array like array("value1","value2")

************************************************************************************/
function theme_select_option($name, $value, $array) {
	$sel[$value] = ' selected="selected"';
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	foreach($array as $var) {
		$select .= '<option'.(isset($sel[$var])?$sel[$var]:'').">$var</option>\n";
	}
	return $select.'</select>';
}
/***********************************************************************************

 string theme_select_box

 Creates a selection dropdown box of all given variables in the multi array
	$name : name for the <select>
	$value: current/default value
	$array: array like array("value1 => title1","value2 => title2")

************************************************************************************/
function theme_select_box($name, $value, $array) {
	$select = '<select class="set" name="'.$name.'" id="'.$name."\">\n";
	foreach($array as $val => $title) {
		$select .= "<option value=\"$val\"".(($val==$value) ? ' selected="selected"' : '').">$title</option>\n";
	}
	return $select.'</select>';
}
